home *** CD-ROM | disk | FTP | other *** search
- /******** bigjob C Program Source Code File (.C) ********/
- /* */
- /* PROGRAM NAME: bigjob Application (bigjob) */
- /* ------------- */
- /* Generated by GPF (Gui Programming Facility) Version 1.3 Level(01) */
- /* */
- /* DATABASE NAME: No */
- /* ------------- */
- /* */
- /* DATE AND TIME: Thu May 27 20:03:25 1993 */
- /* */
- /* Windows 3 */
- /* */
- /* COPYRIGHT: */
- /* ---------- */
- /* Andy Yuen 1993 */
- /* */
- /* REVISION LEVEL: 1.0 */
- /* --------------- */
- /* */
- /* WHAT YOU NEED TO COMPILE THIS PROGRAM: */
- /* -------------------------------------- */
- /* */
- /* REQUIRED FILES: */
- /* --------------- */
- /* */
- /* bigjob.C - Source code */
- /* bigjob.Cmd - Command file to build this program */
- /* bigjob.Mak - Make file for this program */
- /* bigjob.Def - Module definition file */
- /* bigjob.Ext - External definition file */
- /* bigjob.H - Application header file */
- /* bigjob.Ids - Windows header file */
- /* bigjob.L - Linker automatic response file */
- /* bigjob.Rc - Resource file */
- /* */
- /* WINDOWS.H - Windows include file */
- /* STDLIB.H - Miscellaneous function declarations */
- /* STDIO.H - Declarations for standard I/O routines */
- /* STRING.H - String function declarations */
- /* MALLOC.H - Definitions for memory allocation functions */
- /* */
- /* REQUIRED LIBRARIES: */
- /* ------------------- */
- /* */
- /* LIBW.LIB - Windows Dos library */
- /* LLIBCEW.LIB - DosWind mode/standard combined large model C. */
- /* */
- /* REQUIRED PROGRAMS: */
- /* ------------------ */
- /* */
- /* C Compiler */
- /* Linker */
- /* Resource Compiler */
- /* */
- /**********************************************************************/
-
- /**********************************************************************/
- /* */
- /* Include relevant sections of the WINDOWS header file. */
- /* */
- /**********************************************************************/
-
- #include <windows.h> /* Windows include file */
-
- /**********************************************************************/
- /* */
- /* Include C library routine header files */
- /* */
- /**********************************************************************/
-
- #include <stdlib.h> /* Miscellaneous function declarations */
- #include <stdio.h> /* Declarations for standard I/O routines */
- #include <string.h> /* String function declarations */
- #include <malloc.h> /* Definitions for memory allocation */
- #include <math.h>
- /**********************************************************************/
- /* */
- /* Miscellaneous constants Ids */
- /* */
- /**********************************************************************/
-
- #include "bigjob.Ids"
-
- /**********************************************************************/
- /* */
- /* Function prototypes for private C functions */
- /* */
- /**********************************************************************/
-
- #define EXTERN
-
- #include "bigjob.Ext"
-
- /**********************************************************************/
- /* */
- /* STATIC Function prototypes for private C functions */
- /* */
- /**********************************************************************/
-
- static VOID WmCreateMainWindow( PGPFPARMS pGpfParms );
- static VOID WmPaintMainWindow( PGPFPARMS pGpfParms );
- static VOID ActionRep10( PGPFPARMS pGpfParms );
- static VOID ActionRep100( PGPFPARMS pGpfParms );
- static VOID ActionRep1000( PGPFPARMS pGpfParms );
- static VOID ActionRep10000( PGPFPARMS pGpfParms );
- static VOID ActionStart( PGPFPARMS pGpfParms );
- static VOID ActionAbort( PGPFPARMS pGpfParms );
- static VOID CommandMainWindow( PGPFPARMS pGpfParms );
- static VOID InitializeApplication( VOID );
- static VOID EndApplication( VOID );
- int PASCAL WinMain(HANDLE hInst, HANDLE hPrevInstance,
- LPSTR lpCmdLine,int nCmdShow);
-
- /**********************************************************************/
- /* */
- /* Miscellaneous constants */
- /* */
- /**********************************************************************/
- #define EXTRAWORDS (4 * sizeof(LPVOID)) /* Extra window words */
- #define EXTRAWORDS_GPF DLGWINDOWEXTRA
- #define EXTRAWORDS_USR (DLGWINDOWEXTRA + sizeof(LPVOID) )
- #define GPF_PMC_LEVEL 1 /* GpfPmc.lib Level */
-
- #define TID_USERMAX 0x7fff /* Maximum user timer ID */
-
- #define HWND_DESKTOP (HWND)0
- #define HWND_OBJECT (HWND)0
-
- /**********************************************************************/
- /* */
- /* Global variables */
- /* */
- /**********************************************************************/
-
- /*------------------------ General Definitions -----------------------*/
-
- /* Query System preferences set by the user from the Control Panel */
-
- HANDLE hInstance;
- HANDLE hPrevInstance;
- LPSTR lpCmdLine;
- int nCmdShow;
-
- HWND hwndHelp = (HWND)0; /* Help Hwnd */
- EXTERN HWND hwndMainWindow;
-
- /**********************************************************************/
- /* */
- /* Miscellaneous constants bigjob.H */
- /* */
- /**********************************************************************/
-
- #include "bigjob.H"
-
- /****************** Start of main procedure ***************************/
- /**********************************************************************/
- /* */
- /* FUNCTION: WinMain */
- /* */
- /* This is a typical WINDOWS main function. */
- /* */
- /* FUNCTION: WinMain(HANDLE, HANDLE, LPSTR, int) */
- /* */
- /* PURPOSE: calls initialization function, processes message loop. */
- /* */
- /* It initializes WINDOWS, registers some window classes, creates a */
- /* main window, gets and dispatches messages to its window procedure */
- /* until the time to quit, and then tidies up before terminating. */
- /* */
- /**********************************************************************/
-
- int PASCAL WinMain(HANDLE hInst, HANDLE hPrevInst,
- LPSTR CmdLine,int CmdShow)
- {
- MSG msg;
-
- /********************************************************************/
- /* Initialize Application */
- /********************************************************************/
- hInstance = hInst; /* Keep to global variables */
- hPrevInstance = hPrevInst; /* Keep to global variables */
- lpCmdLine = CmdLine; /* Keep to global variables */
- nCmdShow = CmdShow; /* Keep to global variables */
- szTaskList = "BigJob";
- LogoTimer = 3500; /* Logo Timer */
- EndOfAppl = FALSE; /* Switch Accept End Application */
- AcceptMsgInfo = TRUE; /* Accept MsgInfo */
-
- InitializeApplication();
-
- /********************************************************************/
- /* Create the window "MainWindow". */
- /********************************************************************/
- CreateMainWindow(NULL);
-
- /********************************************************************/
- /* Make sure the window was created. */
- /********************************************************************/
- if (!hwndMainWindow)
- return (FALSE);
-
- /********************************************************************/
- /* Show the window "MainWindow". */
- /********************************************************************/
- ShowWindow(hwndMainWindow, nCmdShow);
- ShowMainWindow(NULL); /* Show Main Window */
-
-
- /********************************************************************/
- /* Main message-processing loop - get and dispatch messages until */
- /* WM_QUIT received and Accepted (EndOfAppl = TRUE) */
- /********************************************************************/
- PeekMessageLoop(&msg, &mtask);
-
-
- /********************************************************************/
- /* Tidy up and terminate */
- /********************************************************************/
-
- /********************************************************************/
- /* Dos Exit */
- /********************************************************************/
- return (msg.wParam);
- }
- /**********************************************************************/
- /* End of main procedure */
- /**********************************************************************/
- /**********************************************************************/
-
-
- /**********************************************************************/
- /**********************************************************************/
- /* */
- /* WinProc: GpfDefWindowProc */
- /* */
- /* Controls the "DefaultWindowProc" Area. */
- /* */
- /* */
- /**********************************************************************/
-
- LONG FAR PASCAL GpfDefWindowProc(
- HWND hwnd, USHORT msg, WORD wParam, DWORD dwParam )
- {
- HDC hDC; /* handle Display Context use with the WM_PAINT message */
- PAINTSTRUCT ps; /* Paint structure for Paint functions */
-
- switch(msg)
- {
-
- /**************************************************************/
- /* The application has asked for the window to be destroyed. */
- /**************************************************************/
- case WM_DESTROY:
- GpfDestroyTemplate(hwnd); /* Reset Help Instance */
- break;
-
- /**************************************************************/
- /* Things to do when the Window is Activated/Deactivated */
- /**************************************************************/
- case WM_ACTIVATE:
- if (wParam)
- SetFocus(hwnd);
- return DefDlgProc( hwnd, msg, wParam, dwParam );
-
- /**************************************************************/
- /* Let frame control erase background for us */
- /**************************************************************/
- case WM_ERASEBKGND:
- return( DefDlgProc(hwnd, msg, wParam, dwParam) );
-
- /***************************************************************/
- /* The window needs painting. */
- /***************************************************************/
- case WM_PAINT:
- hDC = BeginPaint( hwnd, &ps );
- FillRect( hDC, &ps.rcPaint, GetStockObject(WHITE_BRUSH) );
- EndPaint( hwnd, &ps );
- break;
-
- /**************************************************************/
- /* Things to do when the Window is Moved */
- /**************************************************************/
- case WM_MOVE:
- PostMessage( hwnd, WM_PAINT, NULL, NULL); /* Paint Inf Msg */
- UpdateWindow(hwnd);
- break;
-
- /***************************************************************/
- /* The List Box needs to know how big to make an Item. */
- /***************************************************************/
- case WM_MEASUREITEM:
- return (LONG)GpfMeasureItem( hwnd, wParam, dwParam );
- break;
-
- /**************************************************************/
- /* The List Box wants us to Draw an Item */
- /**************************************************************/
- case WM_DRAWITEM:
- return (LONG)GpfDrawItem( hwnd, wParam, dwParam );
- break;
-
- /**************************************************************/
- /* Things to do when the Window is End LogoTimer */
- /**************************************************************/
- case WM_TIMER:
- if (wParam != TID_USERMAX)
- return DefDlgProc( hwnd, msg, wParam, dwParam );
- KillTimer(hwnd, TID_USERMAX); /* Stop LogoTimer */
- /**************************************************************/
- /* Simulate CANCEL - Post WM_CLOSE to Window */
- /**************************************************************/
- PostMessage( hwnd, WM_CLOSE, NULL, NULL ); /* Send Message */
- break;
-
- /***************************************************************/
- /* Other messages are handled by the default window procedure. */
- /***************************************************************/
- default:
- /* Pass all other messages to the default window procedure */
- return DefDlgProc( hwnd, msg, wParam, dwParam );
- }
- return ((LONG) FALSE);
- }
- /**********************************************************************/
- /* End of window procedure - WinProc: GpfDefWindowProc */
- /**********************************************************************/
- /**********************************************************************/
-
-
-
- /**********************************************************************/
- /**********************************************************************/
- /* */
- /* PRIVATE FUNCTION : GpfSetCentreWindow */
- /* */
- /* Positions Window in the center of the screen */
- /* */
- /**********************************************************************/
-
- VOID FAR PASCAL GpfSetCentreWindow( HWND hwnd )
- {
-
- int iX, iY;
- int iScreenWidth, iScreenHeight;
- int iWndWidth, iWndHeight;
- RECT rcRect;
-
- /********************************************************************/
- /* Query width and depth of screen device */
- /********************************************************************/
- iScreenWidth = GetSystemMetrics( SM_CXSCREEN );
- iScreenHeight = GetSystemMetrics( SM_CYSCREEN );
-
- /********************************************************************/
- /* Query width and depth of Window */
- /********************************************************************/
- GetWindowRect( hwnd, &rcRect );
-
- /********************************************************************/
- /* Calculate the width and the height of the window */
- /********************************************************************/
- iWndWidth = rcRect.right - rcRect.left;
- iWndHeight = rcRect.bottom - rcRect.top;
-
- /********************************************************************/
- /* Center Window within the screen */
- /********************************************************************/
- iX = ( iScreenWidth - iWndWidth ) / 2;
- iY = ( iScreenHeight - iWndHeight ) / 2;
- SetWindowPos( hwnd, NULL, iX, iY, iWndWidth, iWndHeight, SWP_NOZORDER );
- }
- /**********************************************************************/
- /* End of GpfSetCentreWindow Private Function */
- /**********************************************************************/
- /**********************************************************************/
-
-
-
- /**********************************************************************/
- /**********************************************************************/
- /* */
- /* PRIVATE FUNCTION : GpfSetTopWindow */
- /* */
- /* Positions the Window in the Top of the screen */
- /* */
- /**********************************************************************/
-
- VOID FAR PASCAL GpfSetTopWindow( HWND hwnd )
- {
- int iY;
- int iScreenHeight;
- int iWndWidth, iWndHeight;
- RECT rcRect;
-
- /*******************************************************************/
- /* Query width and depth of screen device */
- /*******************************************************************/
- iScreenHeight = GetSystemMetrics( SM_CYSCREEN );
-
- /*******************************************************************/
- /* Query width and depth of Window */
- /*******************************************************************/
- GetWindowRect( hwnd, &rcRect );
-
- /*******************************************************************/
- /* Calculate the width and the height of the window */
- /*******************************************************************/
- iWndWidth = rcRect.right - rcRect.left;
- iWndHeight = rcRect.bottom - rcRect.top;
-
- /*******************************************************************/
- /* Center Window within the screen */
- /*******************************************************************/
- iY = ( iScreenHeight - iWndHeight );
- SetWindowPos( hwnd, NULL, rcRect.left, iY,
- iWndWidth, iWndHeight, SWP_NOZORDER );
- }
- /**********************************************************************/
- /* End of GpfSetTopWindow Private Function */
- /**********************************************************************/
- /**********************************************************************/
-
-
-
- /**********************************************************************/
- /**********************************************************************/
- /* */
- /* PRIVATE FUNCTION : GpfSetMaxWindow */
- /* */
- /* Positions the Window in the Max of the screen */
- /* */
- /**********************************************************************/
-
- VOID FAR PASCAL GpfSetMaxWindow( HWND hwnd )
- {
- int iScreenWidth, iScreenHeight;
-
- /*******************************************************************/
- /* Query width and depth of screen device */
- /*******************************************************************/
- iScreenWidth = GetSystemMetrics( SM_CXSCREEN );
- iScreenHeight = GetSystemMetrics( SM_CYSCREEN );
-
- /*******************************************************************/
- /* Top Window within the screen */
- /*******************************************************************/
- SetWindowPos( hwnd, NULL, 0 , 0 ,
- iScreenWidth, iScreenHeight, SWP_NOZORDER );
- }
- /**********************************************************************/
- /* End of GpfSetMaxWindow Private Function */
- /**********************************************************************/
- /**********************************************************************/
-
-
- /**********************************************************************/
- /**********************************************************************/
- /* */
- /* PRIVATE FUNCTION: GpfSetDialogBoxSysMenu */
- /* */
- /* Edit items in the system menu to leave "Move", "Close", and */
- /* "Switch to Task Manager". */
- /* */
- /**********************************************************************/
- VOID FAR PASCAL GpfSetDialogBoxSysMenu( HWND hwnd )
- {
- HWND hSysMenu; /* sys menu pull-down handle */
- WORD wItemCount; /* System menu items count */
- int nItemIndex; /* Item index */
- WORD wMenuID; /* Menu Identificator */
-
- /********************************************************************/
- /* Get the handle of the system menu pull-down. */
- /* Destroying existing copy and get the original handle Menu */
- /********************************************************************/
- hSysMenu = GetSystemMenu( hwnd, TRUE );
-
- /********************************************************************/
- /* Remove all items from the system menu pull-down that are no */
- /* longer needed. */
- /********************************************************************/
-
- wItemCount = GetMenuItemCount( hSysMenu );
-
- for ( nItemIndex = (int)wItemCount; nItemIndex != -1; nItemIndex-- )
- {
- wMenuID = GetMenuItemID( hSysMenu, nItemIndex );
- if ( wMenuID != SC_MOVE &&
- wMenuID != SC_CLOSE &&
- wMenuID != SC_TASKLIST )
- DeleteMenu( hSysMenu, nItemIndex, MF_BYPOSITION );
- }
- }
- /**********************************************************************/
- /* End of GpfSetDialogBoxSysMenu Private Function */
- /**********************************************************************/
- /**********************************************************************/
-
- /************** Start of GpfSysMenuGray Private Function **************/
- /**********************************************************************/
- /* GpfSysMenuGray: */
- /* This function enables and disables choices (menu items) as required*/
- /**********************************************************************/
-
- VOID FAR PASCAL GpfSysMenuGray(HWND hwnd, USHORT Item, BOOL option )
- {
- HMENU hSysMenu;
-
- hSysMenu = GetSystemMenu( hwnd, TRUE );
- EnableMenuItem( hSysMenu, Item,
- MF_BYCOMMAND | option ? (MF_GRAYED|MF_DISABLED) : MF_ENABLED);
- }
- /**********************************************************************/
- /*************** End of GpfSysMenuGray Private Function ***************/
- /**********************************************************************/
- /**********************************************************************/
-
-
- /***************** Start of GpfMenuGray Private Function **************/
- /**********************************************************************/
- /* */
- /* PRIVATE FUNCTION : GpfMenuGray */
- /* */
- /* This function enables and disables choices (menu items) as required*/
- /* */
- /**********************************************************************/
-
- VOID FAR PASCAL GpfMenuGray(HWND hwnd, USHORT Item, BOOL option )
- {
- HMENU hMenu;
-
- hMenu = GetMenu( hwnd );
- EnableMenuItem( hMenu, Item,
- MF_BYCOMMAND | option ? (MF_GRAYED|MF_DISABLED) : MF_ENABLED);
- }
- /**********************************************************************/
- /* End of GpfMenuGray Private Function */
- /**********************************************************************/
- /**********************************************************************/
-
-
- /***************** Start of GpfMenuTick Private Function **************/
- /**********************************************************************/
- /* */
- /* PRIVATE FUNCTION : GpfMenuTick */
- /* */
- /* This function updates the check marks against choices as required. */
- /* */
- /**********************************************************************/
- VOID FAR PASCAL GpfMenuTick(HWND hwnd , USHORT Item, BOOL option )
- {
- HMENU hMenu;
-
- hMenu = GetMenu( hwnd );
- CheckMenuItem( hMenu, Item,
- MF_BYCOMMAND | option ? MF_CHECKED : MF_UNCHECKED);
- }
-
- /**********************************************************************/
- /* End of GpfMenuTick Private Function */
- /**********************************************************************/
- /**********************************************************************/
-
-
-
- /************** Start of GpfMenuSwapTick Private Function *************/
- /**********************************************************************/
- /* */
- /* PRIVATE FUNCTION : GpfMenuSwapTick */
- /* */
- /* This function updates-Swap the check marks. */
- /* */
- /**********************************************************************/
- VOID FAR PASCAL GpfMenuSwapTick(HWND hwnd , USHORT Item )
- {
- HMENU hMenu;
-
- hMenu = GetMenu( hwnd );
- if (CheckMenuItem( hMenu, Item, MF_BYCOMMAND | MF_CHECKED))
- CheckMenuItem( hMenu, Item, MF_BYCOMMAND | MF_UNCHECKED);
- }
-
- /**********************************************************************/
- /* End of GpfMenuTick Private Function */
- /**********************************************************************/
- /**********************************************************************/
-
-
-
- /************* Start of GpfStringIsNumeric Private Function ***********/
- /**********************************************************************/
- /* */
- /* PRIVATE FUNCTION : GpfStringIsNumeric */
- /* */
- /**********************************************************************/
- BOOL FAR PASCAL GpfStringIsNumeric( UCHAR String[] )
- {
- SHORT Index;
- SHORT Length;
-
- Length = strlen(String);
- if (!Length)
- return FALSE;
- for (Index = 0; Index < Length; Index++)
- {
- if (String[Index] < '0' || String[Index] > '9')
- return FALSE;
- }
- return TRUE;
- }
-
- /**********************************************************************/
- /* End of GpfStringIsNumeric Private Function */
- /**********************************************************************/
- /**********************************************************************/
-
-
-
- /***************** Start of GpfSendMsg Private Function ***************/
- /**********************************************************************/
- /* */
- /* PRIVATE FUNCTION : GpfSendMsg */
- /* */
- /* Display, and operate the message box window */
- /**********************************************************************/
- SHORT FAR PASCAL GpfSendMsg( SHORT Id )
- {
- UCHAR String[256];
- HWND SysModalWindow;
- USHORT Reply = 0;
- SHORT Alarm = -1;
- SHORT Style = 0;
- PUCHAR Token1 = 0;
- PUCHAR Token2 = 0;
-
- /*********************************************************************/
- /* Save Window (System Modal) */
- /*********************************************************************/
- SysModalWindow = GetSysModalWindow();
-
- /*********************************************************************/
- /* Load Msg strings */
- /*********************************************************************/
- LoadString( hInstance, Id, String, sizeof(String) );
-
- Token1 = strchr(String,':');
- if (Token1)
- {
- *Token1 = 0;
- Alarm = atoi(String);
- Token2 = strchr(++Token1,' ');
- if (Token2)
- {
- *(Token2++) = 0;
- Style = atoi(Token1);
- /***************************************************/
- /* Set Alarm */
- /***************************************************/
- if (Alarm != -1)
- MessageBeep(0);
- /***************************************************/
- /* Now, display the message, save the button press */
- /* for a return code. */
- /* Pop up a Message box. */
- /***************************************************/
- Reply = MessageBox( GetFocus(), Token2,
- szTaskList, Style );
- /***************************************************/
- /* Restore Window (System Modal) */
- /***************************************************/
- if (SysModalWindow)
- SetSysModalWindow(SysModalWindow);
- }
- }
- return(Reply);
- }
-
- /**********************************************************************/
- /* End of GpfSendMsg Private Function */
- /**********************************************************************/
- /**********************************************************************/
-
-
-
- /***************** Start of GpfSendMsgInfo Function *******************/
- /**********************************************************************/
- /* */
- /* FUNCTION : GpfSendMsgInfo */
- /* */
- /* Display, and operate the message */
- /**********************************************************************/
- VOID FAR PASCAL GpfSendMsgInfo( PGPFPARMS pGpfParms, USHORT ShortMsgId )
- {
- if (pGpfParms->ShortMsgId == ShortMsgId)
- return;
- if (!(AcceptMsgInfo | pGpfParms->ShortMsgId))
- return;
- if (!(AcceptMsgInfo)) /* Accept Msg Info ... */
- pGpfParms->ShortMsgId = 0; /* No... Reset MsgId */
- else
- pGpfParms->ShortMsgId = ShortMsgId; /* Save Msg Id */
- GpfDisplayMsgInformation( pGpfParms );
- }
- /**********************************************************************/
- /* End of GpfSendMsgInfo Function */
- /**********************************************************************/
- /**********************************************************************/
-
-
- /**********************************************************************/
- /**********************************************************************/
- /* */
- /* PRIVATE FUNCTION: Initialize Application */
- /* */
- /**********************************************************************/
-
- static VOID InitializeApplication( VOID )
- {
- }
- /**********************************************************************/
- /* End of Private Function: Initialize Application */
- /**********************************************************************/
- /**********************************************************************/
-
-
-
- /**********************************************************************/
- /**********************************************************************/
- /* */
- /* PRIVATE FUNCTION: End Application */
- /* */
- /**********************************************************************/
-
- static VOID EndApplication( VOID )
- {
-
- EndOfAppl = TRUE;
-
- }
- /**********************************************************************/
- /* End of Private Function: End Application */
- /**********************************************************************/
- /**********************************************************************/
-
-
-
- /**********************************************************************/
- /**********************************************************************/
- /* */
- /* STATIC PRIVATE FUNCTION: WmCreateMainWindow */
- /* */
- /* WM_CREATE - Create - "MainWindow". */
- /* */
- /**********************************************************************/
-
- static VOID WmCreateMainWindow ( PGPFPARMS pGpfParms )
- {
- pGpfParms->mresult = (LONG) FALSE; /* Set Return Code */
- CreateThreads();
- }
- /**********************************************************************/
- /* End of Function: WmCreateMainWindow */
- /**********************************************************************/
- /**********************************************************************/
-
-
-
- /**********************************************************************/
- /**********************************************************************/
- /* */
- /* STATIC PRIVATE FUNCTION: WmPaintMainWindow */
- /* */
- /* WM_PAINT - Paint - "MainWindow". */
- /* */
- /**********************************************************************/
-
- static VOID WmPaintMainWindow ( PGPFPARMS pGpfParms )
- {
- pGpfParms->mresult = (LONG) FALSE; /* Set Return Code */
- PaintWindow(pGpfParms);
- }
- /**********************************************************************/
- /* End of Function: WmPaintMainWindow */
- /**********************************************************************/
- /**********************************************************************/
-
-
- /**********************************************************************/
- /**********************************************************************/
- /* */
- /* FUNCTION: ShowMainWindow */
- /* */
- /* Show Window "MainWindow". */
- /* */
- /**********************************************************************/
-
- BOOL ShowMainWindow( LPVOID pCrtParms )
- {
-
- /* Make sure the window was not created. */
- if (!hwndMainWindow)
- CreateMainWindow( pCrtParms );
- ShowWindow( hwndMainWindow, SW_SHOWNORMAL );
- UpdateWindow( hwndMainWindow );
- SetFocus( hwndMainWindow );
- return(FALSE);
- }
- /**********************************************************************/
- /* End of Function - ShowMainWindow */
- /**********************************************************************/
- /**********************************************************************/
-
-
-
- /**********************************************************************/
- /**********************************************************************/
- /* */
- /* FUNCTION: DismissMainWindow */
- /* */
- /* Dismiss Window Hide - Window "MainWindow". */
- /* */
- /**********************************************************************/
-
- VOID DismissMainWindow( BOOL Rcode )
- {
-
- Rcode = Rcode; /* Null , For Delete Unreferenced Formal Parameter */
- /* Hide Window */
- ShowWindow( hwndMainWindow, SW_HIDE );
-
- }
- /**********************************************************************/
- /* End of Function - DismissMainWindow */
- /**********************************************************************/
- /**********************************************************************/
-
-
-
- /**********************************************************************/
- /**********************************************************************/
- /* */
- /* FUNCTION: CreateMainWindow */
- /* */
- /* Create the window "MainWindow" And Controls. */
- /* */
- /**********************************************************************/
-
- VOID CreateMainWindow( LPVOID pCrtParms )
- {
- WNDCLASS wc;
-
- /********************************************************************/
- /* Register the window class "MainWindow". */
- /********************************************************************/
- wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS;
- wc.lpfnWndProc = fnwpMainWindow; /* Window procedure */
- wc.cbClsExtra = EXTRAWORDS;
- wc.cbWndExtra = DLGWINDOWEXTRA + EXTRAWORDS;
- wc.hInstance = hInstance;
- wc.hIcon = LoadIcon( hInstance, MAKEINTRESOURCE(ID_MAINWINDOW) );
- wc.hCursor = LoadCursor( NULL, IDC_ARROW );
- wc.hbrBackground = (HBRUSH)CTLCOLOR_DLG;
- wc.lpszMenuName = "MainWindow"; /* Window Menu name */
- wc.lpszClassName = "MainWindow"; /* Window class name */
- RegisterClass( &wc );
-
- /********************************************************************/
- /* Create the window "MainWindow". */
- /********************************************************************/
- hwndMainWindow = /* Save Hwnd */
- GpfCreateTemplate( hInstance,
- "MainWindow", /* Template Name */
- HWND_DESKTOP, /* Hwnd Owner */
- ID_MAINWINDOW, /* Id */
- pCrtParms ); /* Create Parms */
- }
- /**********************************************************************/
- /* End of Function - CreateMainWindow */
- /**********************************************************************/
- /**********************************************************************/
-
-
-
- /**********************************************************************/
- /**********************************************************************/
- /* */
- /* WinProc: fnwpMainWindow */
- /* */
- /* Controls the "MainWindow" Area. */
- /* */
- /* */
- /**********************************************************************/
-
- LONG FAR PASCAL fnwpMainWindow(
- HWND hwnd, USHORT msg, WORD wParam, DWORD dwParam )
- {
- static GPFPARMS GpfParms; /* Gpf Parameters */
- PGPFPARMS pGpfParms; /* Far Pointer */
- LONG mresult; /* Work mresult */
- USHORT uShort; /* Work uShort */
- /*******************************************************************/
- /* Initialize Gpf Parameters */
- /*******************************************************************/
- pGpfParms = &GpfParms; /* Initialize Gpf Parameters */
- pGpfParms->hwnd = hwnd; /* window handle */
- pGpfParms->msg = msg; /* message number */
- pGpfParms->wParam = wParam; /* 1st (packed) parms */
- pGpfParms->dwParam = dwParam; /* 2nd (packed) parms */
- pGpfParms->mresult = (LONG)FALSE; /* Mresult */
- pGpfParms->hdc = (HDC)0; /* Paint (HDC) */
- pGpfParms->Command = 0; /* Command From wParam (SHORT 1) */
- pGpfParms->Notify = 0; /* Notify From wParam (SHORT 2) */
-
- mresult = (LONG)NULL; /* Work mresult */
- uShort = 0; /* Work uShort */
-
- switch(msg)
- {
- /**************************************************************/
- /* Things to do when the Window is first initalized */
- /**************************************************************/
- case WM_INITDIALOG:
- pGpfParms->pCrtParms = (LPVOID) dwParam;
- return (pGpfParms->mresult);
-
-
- /**************************************************************/
- /* The application has asked for the window to be created. */
- /**************************************************************/
- case WM_CREATE:
- hwndMainWindow = hwnd; /* Save Hwnd */
- pGpfParms->BgColor = (HBRUSH)CTLCOLOR_DLG;
- pGpfParms->hInstance = hInstance;
- pGpfParms->ShortMsgId = 0; /* Current Short Message Id */
- WmCreateMainWindow( pGpfParms ); /* Create Window */
- return GpfDefWindowProc( hwnd, msg, wParam, dwParam );
-
- /**************************************************************/
- /* The application has asked for the window to be destroyed. */
- /**************************************************************/
- case WM_DESTROY:
- GpfDestroyTemplate( hwnd ); /* Reset Help Instance */
- hwndMainWindow = (HWND)NULL; /* Reset Hwnd */
- return GpfDefWindowProc( hwnd, msg, wParam, dwParam );
-
- /**************************************************************/
- /* The window needs EraseBackGround. */
- /**************************************************************/
- case WM_ERASEBKGND:
- return( DefDlgProc(hwnd, msg, wParam, dwParam) );
-
- /**************************************************************/
- /* The window needs Ctl Color. */
- /**************************************************************/
- case WM_CTLCOLOR:
- SetBkMode((HDC)wParam,TRANSPARENT);
- return(pGpfParms->BgColor);
-
- /**************************************************************/
- /* The window needs painting. */
- /**************************************************************/
- case WM_PAINT:
- /**************************************************************/
- /* Obtain a cache PS */
- /**************************************************************/
- pGpfParms->hdc = BeginPaint( hwnd, &pGpfParms->ps );
- WmPaintMainWindow( pGpfParms ); /* Paint Window */
- EndPaint( hwnd, &pGpfParms->ps );
- return (LONG)FALSE;
-
- /**************************************************************/
- /* Process ScrollBar received from the user */
- /**************************************************************/
- case WM_HSCROLL:
- case WM_VSCROLL:
- pGpfParms->Notify = wParam;
- pGpfParms->Command = HIWORD( dwParam );
- CommandMainWindow( pGpfParms ); /* Process the command */
- return (pGpfParms->mresult);
-
- /**************************************************************/
- /* Process commands received from the user */
- /**************************************************************/
- case WM_SYSCOMMAND:
- case WM_COMMAND:
- /* Set Command From wParam */
- pGpfParms->Command = wParam;
- pGpfParms->Notify = HIWORD( dwParam );
- CommandMainWindow( pGpfParms ); /* Process the command */
- return GpfDefWindowProc( hwnd, msg, wParam, dwParam );
-
- /**************************************************************/
- /* Message from system to close the client window. */
- /**************************************************************/
- case WM_CLOSE:
- pGpfParms->Command = IDCANCEL;
- pGpfParms->Notify = BN_CLICKED;
- CommandMainWindow( pGpfParms ); /* Process the command */
- if (!pGpfParms->mresult)
- PostQuitMessage( 0 ); /* Cause termination */
-
- /**************************************************************/
- /* All other messages are passed to the default procedure. */
- /**************************************************************/
- default:
- /* Pass all other messages to the default window procedure */
- return GpfDefWindowProc( hwnd, msg, wParam, dwParam );
- }
- return ((LONG)FALSE);
- }
- /**********************************************************************/
- /* End of window procedure - WinProc: fnwpMainWindow */
- /**********************************************************************/
- /**********************************************************************/
-
-
-
- /**********************************************************************/
- /**********************************************************************/
- /* */
- /* PRIVATE FUNCTION: CommandMainWindow */
- /* */
- /* Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
- /* received by the window procedure. */
- /* Window "MainWindow". */
- /* */
- /**********************************************************************/
-
- static VOID CommandMainWindow ( PGPFPARMS pGpfParms )
- {
- pGpfParms->mresult = (LONG)TRUE; /* Set Return Code */
- /* Switch according to Control chosen */
- switch( pGpfParms->Command )
- {
- /******************************************************************/
- /* Name "Rep10". */
- /* Text "10". */
- /******************************************************************/
- case ID_REP10:
- ActionRep10(pGpfParms);
- return;
- /******************************************************************/
- /* Name "Rep100". */
- /* Text "100". */
- /******************************************************************/
- case ID_REP100:
- ActionRep100(pGpfParms);
- return;
- /******************************************************************/
- /* Name "Rep1000". */
- /* Text "1000". */
- /******************************************************************/
- case ID_REP1000:
- ActionRep1000(pGpfParms);
- return;
- /******************************************************************/
- /* Name "Rep10000". */
- /* Text "10000". */
- /******************************************************************/
- case ID_REP10000:
- ActionRep10000(pGpfParms);
- return;
- /******************************************************************/
- /* Name "Start". */
- /* Text "~Start". */
- /******************************************************************/
- case ID_START:
- ActionStart(pGpfParms);
- return;
- /******************************************************************/
- /* Name "Abort". */
- /* Text "~Abort". */
- /******************************************************************/
- case ID_ABORT:
- ActionAbort(pGpfParms);
- return;
- }
- /* Take no action for any other selections */
- pGpfParms->mresult = (LONG)FALSE; /* Set Return Code */
- }
- /**********************************************************************/
- /* End of Private Function: CommandMainWindow */
- /**********************************************************************/
- /**********************************************************************/
-
-
- /**********************************************************************/
- /**********************************************************************/
- /* */
- /* STATIC PRIVATE FUNCTION: ActionRep10 */
- /* */
- /* Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
- /* received by the window procedure. */
- /* Window "MainWindow". */
- /* */
- /**********************************************************************/
-
- static VOID ActionRep10( PGPFPARMS pGpfParms )
- {
- /* Switch according to Control chosen */
- switch( pGpfParms->Notify )
- {
- case BN_CLICKED:
- SelectRep(pGpfParms);
- return;
- }
- /* Take no action for any other selections */
- }
- /**********************************************************************/
- /* End of Private Function */
- /**********************************************************************/
- /**********************************************************************/
-
-
- /**********************************************************************/
- /**********************************************************************/
- /* */
- /* STATIC PRIVATE FUNCTION: ActionRep100 */
- /* */
- /* Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
- /* received by the window procedure. */
- /* Window "MainWindow". */
- /* */
- /**********************************************************************/
-
- static VOID ActionRep100( PGPFPARMS pGpfParms )
- {
- /* Switch according to Control chosen */
- switch( pGpfParms->Notify )
- {
- case BN_CLICKED:
- SelectRep(pGpfParms);
- return;
- }
- /* Take no action for any other selections */
- }
- /**********************************************************************/
- /* End of Private Function */
- /**********************************************************************/
- /**********************************************************************/
-
-
- /**********************************************************************/
- /**********************************************************************/
- /* */
- /* STATIC PRIVATE FUNCTION: ActionRep1000 */
- /* */
- /* Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
- /* received by the window procedure. */
- /* Window "MainWindow". */
- /* */
- /**********************************************************************/
-
- static VOID ActionRep1000( PGPFPARMS pGpfParms )
- {
- /* Switch according to Control chosen */
- switch( pGpfParms->Notify )
- {
- case BN_CLICKED:
- SelectRep(pGpfParms);
- return;
- }
- /* Take no action for any other selections */
- }
- /**********************************************************************/
- /* End of Private Function */
- /**********************************************************************/
- /**********************************************************************/
-
-
- /**********************************************************************/
- /**********************************************************************/
- /* */
- /* STATIC PRIVATE FUNCTION: ActionRep10000 */
- /* */
- /* Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
- /* received by the window procedure. */
- /* Window "MainWindow". */
- /* */
- /**********************************************************************/
-
- static VOID ActionRep10000( PGPFPARMS pGpfParms )
- {
- /* Switch according to Control chosen */
- switch( pGpfParms->Notify )
- {
- case BN_CLICKED:
- SelectRep(pGpfParms);
- return;
- }
- /* Take no action for any other selections */
- }
- /**********************************************************************/
- /* End of Private Function */
- /**********************************************************************/
- /**********************************************************************/
-
-
- /**********************************************************************/
- /**********************************************************************/
- /* */
- /* STATIC PRIVATE FUNCTION: ActionStart */
- /* */
- /* Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
- /* received by the window procedure. */
- /* Window "MainWindow". */
- /* */
- /**********************************************************************/
-
- static VOID ActionStart( PGPFPARMS pGpfParms )
- {
- /* Switch according to Control chosen */
- switch( pGpfParms->Notify )
- {
- case BN_CLICKED:
- StartSalvage(pGpfParms);
- return;
- }
- /* Take no action for any other selections */
- }
- /**********************************************************************/
- /* End of Private Function */
- /**********************************************************************/
- /**********************************************************************/
-
-
- /**********************************************************************/
- /**********************************************************************/
- /* */
- /* STATIC PRIVATE FUNCTION: ActionAbort */
- /* */
- /* Takes appropriate action when a WM_COMMAND/WM_CONTROL message is */
- /* received by the window procedure. */
- /* Window "MainWindow". */
- /* */
- /**********************************************************************/
-
- static VOID ActionAbort( PGPFPARMS pGpfParms )
- {
- /* Switch according to Control chosen */
- switch( pGpfParms->Notify )
- {
- case BN_CLICKED:
- AbortSalvage(pGpfParms);
- return;
- }
- /* Take no action for any other selections */
- }
- /**********************************************************************/
- /* End of Private Function */
- /**********************************************************************/
- /**********************************************************************/
-
-